#include <iostream>


using namespace std;
/**
 * 算法思想：在星期一到星期五，distance每执行一次加250，星期天需将week重置为1
 * @return
 */
int main() {
    int week; //星期几
    int n;  //天数
    long distance =0;
    scanf("%d%d", &week, &n);
    if ((1 <= week && 7 >= week) && (1 <= n && 1000000 >= n)) {
        for (int i = 0; i <= n; ++i) {
            if (week != 6 && week != 7){
                distance= distance+250;
            }
            if (week==7){
                week=1;
            }else{
                week++;
            }
        }
        printf("%ld",distance);
    }
    return 0;
}
